package studyStream;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.stream.Stream;

public class StartWayStream {
    public static void main(String[] args) {
        //单列集合获取stream流
        ArrayList<String> list1 = new ArrayList<>();
        Collections.addAll(list1, "徐瑞琪", "徐添琪", "徐锦慧", "徐锦媛", "徐烨");
        list1.stream().filter(s -> s.startsWith("徐")).filter(s -> s.length() == 3).forEach(s -> System.out.println(s));
        System.out.println("========================");
        //双列集合获取Stream流
        HashMap<Integer, Integer> hm = new HashMap<>();
        hm.put(1, 1);
        hm.put(2, 1);
        hm.put(3, 1);
        hm.put(4, 1);
        hm.keySet().stream().forEach(num -> System.out.println(num));
        System.out.println("========================");
        //数组获取stream流
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9};
        Arrays.stream(arr).forEach(i -> System.out.println(i));
        System.out.println("========================");
        //零散数据
        Stream.of('1', '1', '1', '1', '1').forEach(c -> System.out.println(c));
    }
}
